package com.health.db.dao.order.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.health.db.dao.ServiceInterface;
import com.health.db.dao.order.IDateStuffScheduleDao;
import com.health.db.mapper.DateStuffScheduleMapper;
import com.health.db.model.DateStuffSchedule;
import com.health.db.model.DateStuffScheduleExample;
import com.health.redis.RedisConstants;

/**
 * 科室医生
 * @author YC
 *
 */
@Component("dateStuffScheduleDao")
public class DateStuffScheduleImpl extends ServiceInterface implements
		IDateStuffScheduleDao{

	@Autowired
	DateStuffScheduleMapper dateStuffScheduleMapper;

	@Override
	public List<DateStuffSchedule> selectByExample(DateStuffScheduleExample example) {
		// TODO Auto-generated method stub
		
		getRedisOperatiorLogic();
	    String key =RedisConstants.NEWDateStuffScheduleMapper+":date:"+example.getScheduleDate();
	    
	    Integer departmentId = example.getDepartmentId();

	    if (null!=departmentId&&departmentId.intValue()!=0) {
	    	key =key+":dpId:"+departmentId.intValue();	
		}
	    
	    Object object=null;
	    List<DateStuffSchedule>  list = null;
      
        if(redisOperatiorLogic.isJedisIsConnected())
        {    
            object = redisOperatiorLogic.readObject(key, getPublicRedisGroupNo("1"));
         }
         if(null!=object){
        	 if (!object.equals("")) {
        		 list = (List<DateStuffSchedule>) object;
			}
         }else{
        	 list= dateStuffScheduleMapper.selectByExample(example);
          if(redisOperatiorLogic.isJedisIsConnected())
            {
                redisOperatiorLogic.setEx(key, list,  getOrderRedisGroupNo("1"));
             }
         }
        return list;
	}




	public DateStuffScheduleMapper getDateStuffScheduleMapper() {
		return dateStuffScheduleMapper;
	}




	public void setDateStuffScheduleMapper(
			DateStuffScheduleMapper dateStuffScheduleMapper) {
		this.dateStuffScheduleMapper = dateStuffScheduleMapper;
	}
	
	
	

}
